package com.taobaolite.history;

import com.taobaolite.item.Item;
import com.taobaolite.user.User;

import javax.persistence.*;
import java.sql.Timestamp;

@Table(name = "history")
@Entity
public class History {

    @EmbeddedId
    @Column(nullable = false, updatable = false, unique = true)
    private HistoryPK historyPK;
    @Column(nullable = false)
    private Boolean deleted;
    @ManyToOne
    @JoinColumn(name = "itemId")
    private Item item;

    public HistoryPK getHistoryPK() {
        return historyPK;
    }

    public void setHistoryPK(HistoryPK historyPK) {
        this.historyPK = historyPK;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    public History(){}
    public History(Timestamp timestamp, User user, Boolean deleted, Item item) {

        this.historyPK = new HistoryPK(user, timestamp);
        this.deleted = deleted;
        this.item = item;
    }
}
